powerstep 2.2.0
Loading...
Searching...
No Matches
powerstep


Power Step Click

Power Step Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Apr 2025.
  • Type : GPIO type

Software Support

Example Description

This example demonstrates the use of the Power Step Click board by driving the motor in both directions for a desired number of steps.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.PowerStep

Example Key Functions

  • powerstep_cfg_setup This function initializes Click configuration structure to initial values.
    void powerstep_cfg_setup(powerstep_cfg_t *cfg)
    Power Step configuration object setup function.
    Power Step Click configuration object.
    Definition powerstep.h:135
  • powerstep_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t powerstep_init(powerstep_t *ctx, powerstep_cfg_t *cfg)
    Power Step initialization function.
    Power Step Click context object.
    Definition powerstep.h:122
  • powerstep_reset_device This function resets the device by setting the RST pin logic state.
    void powerstep_reset_device(powerstep_t *ctx)
    Power Step reset device function.
  • powerstep_drive_motor This function drives the motor for the specific number of steps at the selected speed.
    void powerstep_drive_motor ( powerstep_t *ctx, uint32_t steps, uint8_t speed );
    void powerstep_drive_motor(powerstep_t *ctx, uint32_t steps, uint8_t speed)
    Power Step driver motor function.

Application Init

Initializes the driver and resets the device.

void application_init ( void )
{
log_cfg_t log_cfg;
powerstep_cfg_t powerstep_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
powerstep_cfg_setup( &powerstep_cfg );
POWERSTEP_MAP_MIKROBUS( powerstep_cfg, MIKROBUS_1 );
if ( DIGITAL_OUT_UNSUPPORTED_PIN == powerstep_init( &powerstep, &powerstep_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
powerstep_reset_device ( &powerstep );
log_info( &logger, " Application Task " );
}
#define POWERSTEP_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition powerstep.h:108
void application_init(void)
Definition main.c:30

Application Task

Drives the motor clockwise for 100 slow steps and 300 medium speed steps and then counter-clockwise for 400 fast steps with a 1 second delay on driving mode change. All data is being logged on the USB UART where you can track the program flow.

void application_task ( void )
{
log_printf ( &logger, " Move 100 steps clockwise, speed: slow\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 300 steps clockwise, speed: medium\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 400 steps counter-clockwise, speed: fast\r\n\n" );
Delay_ms ( 1000 );
}
#define POWERSTEP_SPEED_FAST
Definition powerstep.h:89
#define POWERSTEP_SPEED_MEDIUM
Definition powerstep.h:88
#define POWERSTEP_SPEED_SLOW
Definition powerstep.h:87
#define POWERSTEP_DIR_CW
Power Step direction setting.
Definition powerstep.h:72
#define POWERSTEP_DIR_CCW
Definition powerstep.h:73
void powerstep_set_direction(powerstep_t *ctx, uint8_t dir)
Power Step set direction function.
void application_task(void)
Definition main.c:62

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.